<%--
  Created by IntelliJ IDEA.
  User: Ly
  Date: 2017/9/19
  Time: 19:10
  Content:
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script>
        <%--$(function () {--%>
        <%--$("#sortHead").headSort();--%>

        <%--<shiro:hasPermission name="ext:push:view">--%>
        <%--$("#pagedTable tbody tr").dblclick(function (eventObj) {--%>
        <%--var nodeName = eventObj.target.nodeName.toLowerCase();--%>
        <%--if (nodeName != "input" && nodeName != "select" && nodeName != "textarea") {--%>
        <%--location.href = $("#view_opt_" + $(this).attr("beanid")).attr('href');--%>
        <%--}--%>
        <%--});--%>
        <%--</shiro:hasPermission>--%>
        <%--});--%>

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optSingle(opt) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (Cms.checkeds("ids") > 1) {
                alert("<s:message code='pleaseSelectOne'/>");
                return false;
            }
            var id = $("input[name='ids']:checkbox:checked").val();
            location.href = $(opt + id).attr("href");
        }

        function optMulti(form, action, msg) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }

        function optMultis(form, action, msg) {
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>启动后的定时任务管理 - <s:message code="list"/>
    </h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">
            <form method="post">
                    <div class="form-group">
                        <label for="search_EQ_status">定时任务</label>
                        <select class="form-control" name="search_EQ_status" id="search_EQ_status" style="width: 10%">
                            <f:option value="ITP" selected="${isType}">计划中的任务</f:option>
                            <f:option value="TRZ" selected="${isType}">正在运行的任务</f:option>
                        </select>

                        <button class="btn btn-default btn-sm" type="submit"
                                onclick="return optMultis(this.form,'getAllJob.do?isType='+$('#search_EQ_status').val())">
                            <s:message code="search"/></button>
                    </div>

                <div class="btn-toolbar ls-btn-bar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:task:setUpJobDel">
                            <button class="btn btn-default" type="button"
                                    onclick="return optMulti(this.form,'setUpJob.do?cmd=stop&isType='+$('#search_EQ_status').val());">
                                删除任务
                            </button>
                        </shiro:hasPermission>
                    </div>
                </div>

                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}"
                           pageurl="list.do?page_sort={0}&page_sort_dir={1}&${searchstringnosort}">
                    <tr>
                        <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="120"><s:message code="pushMsg.operate"/></th>
                        <th width="30" class="ls-th-sort"><span class="ls-sort" pagesort="id">ID</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="title">名称</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="pushTime">分组</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="pushState">启动状态</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="pushState">任务状态</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="pushTitle">表达式</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="messageId">时间</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="pushTitle">操作</span></th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${typeList}">
                        <tr beanid="${bean.id}">
                            <td align="center"><input type="checkbox" name="ids" value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.user.username}"/></td>
                            <td align="center"><c:out value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.jobName}"/></td>
                            <td align="center"><c:out value="${bean.jobGroup}"/></td>
                            <td align="center"><s:message code="task.jobStatus.${bean.jobStatus}"/></td>
                            <td align="center"><s:message code="task.isRestore.${bean.isRestore}"/></td>
                            <td align="center"><c:out value="${bean.cronExpression}"/></td>
                            <td align="center">
                                原始: <fmt:formatDate value="${bean.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></br>
                                更新: <fmt:formatDate value="${bean.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                            </td>
                            <td align="center">
                                <shiro:hasPermission name="ext:task:setUpJobRestore">
                                    <a href="setUpJob.do?ids=${bean.id}&isRestore=1" class="ls-opt">恢复</a>
                                </shiro:hasPermission>
                                <shiro:hasPermission name="ext:task:setUpJobSuspended">
                                    <a href="setUpJob.do?ids=${bean.id}&isRestore=2" class="ls-opt">暂停</a>
                                </shiro:hasPermission>
                                <%--<shiro:hasPermission name="ext:task:setUpJobExecuted">--%>
                                    <%--<a href="setUpJob.do?ids=${bean.id}&isRestore=0" class="ls-opt">立即执行</a>--%>
                                <%--</shiro:hasPermission>--%>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <%--<c:if test="${fn:length(pagePushList.content) le 0}">--%>
                <%--<div class="ls-norecord"><s:message code="recordNotFound"/></div>--%>
                <%--</c:if>--%>
            </form>
            <%--<form action="list.do" method="get" class="ls-page">--%>
            <%--<tags:search_params excludePage="true"/>--%>
            <%--<tags:pagination pagedList="${pagePushList}"/>--%>
            <%--</form>--%>
        </div>
    </div>
</div>
</body>
</html>